<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html>
<html lang="en">
	<head>
	<base href="<%=basePath%>"><!-- jsp文件头和头部 -->
	<%@ include file="../../system/admin/top.jsp"%> 
	</head>
<body>
	
	<form action="recruit/list.do" method="post" name="Form" id="Form">
		<p class="operate">
	        <a class="create Operate" title="新增" href="<%=basePath%>recruit/goAdd.do" target="opFrame">新增</a>
	        <a class="delete" onclick="makeAll();" title="批量删除">批量删除</a>
    	</p>
		<table id="table_report" class="table table-striped table-bordered table-hover">
			<colgroup>
	           <col width="2%">
	           <col width="5%">
	           <col width="5%">
	           <col width="8%">
	           <col width="8%">
	           <col width="8%">
	           <col width="6%">
	           <col width="13%">
	           <col width="10%">
	           <col width="13%">
	        </colgroup>
		<thead>
			<tr>
				<th><input type="checkbox" id="zcheckbox"></th>
				<th class="center">序号</th>
				<th class="center">申请人</th>
				<th class="center">用人部门</th>
				<th class="center">联系方式</th>
				<th class="center">招聘岗位</th>
				<th class="center">需求人数</th>
				<th class="center">用人要求</th>
				<th class="center">预计到岗时间</th>
				<th class="center">操作</th>
			</tr>
		</thead>
				
		<tbody>
		<!-- 开始循环 -->	
			<c:choose>
				<c:when test="${not empty varList}">
					<c:if test="${QX.cha == 1 }">
					<c:forEach items="${varList}" var="var" varStatus="vs">
						<tr>
							<td class='center' style="width: 30px;">
								<label><input type='checkbox' name='ids' value="${var.recruit_id}" /><span class="lbl"></span></label>
							</td>
							<td class='center' style="width: 30px;">${vs.index+1}</td>
							<td>${var.username}</td>
							<td>
								<c:forEach items="${deptList}" var="department">
									<c:if test="${var.department_id==department.departmentId}">${department.departmentName }</c:if>
								</c:forEach>
							</td>
							<td>${var.recruit_phone}</td>
							<td>${var.recruit_post}</td>
							<td>${var.recruit_number}</td>
							<td>${var.recruit_require}</td>
							<td>
								<fmt:formatDate value="${var.recruit_predicttime}" pattern="yyyy-MM-dd"/>
							<td>
						    <p class="operate">
						    	<c:if test="${QX.edit != 1 && QX.del != 1 }">
								<!-- 无权限 -->
								</c:if>
								<c:if test="${QX.edit == 1 }">
								<a class="revise Operate" title="修改" href="<%=basePath%>recruit/goEdit.do?recruit_id=${var.recruit_id}"  target="opFrame">修改</a>
								</c:if>
								<c:if test="${QX.del == 1 }">
									<a class="delete" title="删除" onclick="del('${var.car_id}');">删除</a>
								</c:if>
		                    </p>
						</td>
						</tr>
					</c:forEach>
					</c:if>
					<c:if test="${QX.cha == 0 }">
						<tr>
							<td colspan="100" class="center">您无权查看</td>
						</tr>
					</c:if>
				</c:when>
				<c:otherwise>
					<tr class="main_info">
						<td colspan="100" class="center" >没有相关数据</td>
					</tr>
				</c:otherwise>
			</c:choose>
		</tbody>
		</table>
	<!--分页器-->
    <div class="branchPage">${page.pageStr}</div>
	</form>
</body>
<script type="text/javascript">

//新增
function add(){
	 top.jzts();
	 var diag = new top.Dialog();
	 diag.Drag=true;
	 diag.Title ="新增";
	 diag.URL = '<%=basePath%>recruit/goAdd.do';
	 diag.Width = 450;
	 diag.Height = 355;
	 diag.CancelEvent = function(){ //关闭事件
		 if(diag.innerFrame.contentWindow.document.getElementById('zhongxin').style.display == 'none'){
			 if('${page.currentPage}' == '0'){
				 top.jzts();
				 setTimeout("self.location=self.location",100);
			 }else{
				 nextPage(${page.currentPage});
			 }
		}
		diag.close();
	 };
	 diag.show();
}

//删除
function del(Id){
	bootbox.confirm("确定要删除吗?", function(result) {
		if(result) {
			top.jzts();
			var url = "<%=basePath%>recruit/delete.do?RECRUIT_ID="+Id+"&tm="+new Date().getTime();
			$.get(url,function(data){
				nextPage(${page.currentPage});
			});
		}
	});
}

//修改
function edit(Id){
	 top.jzts();
	 var diag = new top.Dialog();
	 diag.Drag=true;
	 diag.Title ="编辑";
	 diag.URL = '<%=basePath%>recruit/goEdit.do?RECRUIT_ID='+Id;
	 diag.Width = 450;
	 diag.Height = 355;
	 diag.CancelEvent = function(){ //关闭事件
		 if(diag.innerFrame.contentWindow.document.getElementById('zhongxin').style.display == 'none'){
			 nextPage(${page.currentPage});
		}
		diag.close();
	 };
	 diag.show();
}
</script>

<script type="text/javascript">

$(function() {
	
	//日期框
	$('.date-picker').datepicker();
	
	//复选框
	$('table th input:checkbox').on('click' , function(){
		var that = this;
		$(this).closest('table').find('tr > td:first-child input:checkbox')
		.each(function(){
			this.checked = that.checked;
			$(this).closest('tr').toggleClass('selected');
		});
			
	});
	
});


//批量操作
function makeAll(msg){
	bootbox.confirm(msg, function(result) {
		if(result) {
			var str = '';
			for(var i=0;i < document.getElementsByName('ids').length;i++)
			{
				  if(document.getElementsByName('ids')[i].checked){
				  	if(str=='') str += document.getElementsByName('ids')[i].value;
				  	else str += ',' + document.getElementsByName('ids')[i].value;
				  }
			}
			if(str==''){
				bootbox.dialog("您没有选择任何内容!", 
					[
					  {
						"label" : "关闭",
						"class" : "btn-small btn-success",
						"callback": function() {
							//Example.show("great success");
							}
						}
					 ]
				);
				
				$("#zcheckbox").tips({
					side:3,
		            msg:'点这里全选',
		            bg:'#AE81FF',
		            time:8
		        });
				
				return;
			}else{
				if(msg == '确定要删除选中的数据吗?'){
					top.jzts();
					$.ajax({
						type: "POST",
						url: '<%=basePath%>recruit/deleteAll.do?tm='+new Date().getTime(),
				    	data: {DATA_IDS:str},
						dataType:'json',
						//beforeSend: validateData,
						cache: false,
						success: function(data){
							 $.each(data.list, function(i, list){
									nextPage(${page.currentPage});
							 });
						}
					});
				}
			}
		}
	});
}

//导出excel
function toExcel(){
	window.location.href='<%=basePath%>recruit/excel.do';
}
</script>
</html>

